<template>
	<view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			// 上传图片
			beforeUpload(types) {
				var that=this;
				var token = uni.getStorageSync('token');
				console.log(types);
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function (res) {
						var ss=res.tempFilePaths;
						that.imgurl=ss[0];
						uni.uploadFile({
							url: `${baseUrl}`+'upload',
							// url: "/dpc" + 'upload',
							filePath: ss[0], // 本地上传完成后的路径
							name: 'file', 
							formData: {},
							header:{"token": token},
							success: function(uploadFileRes) {
								var ret=JSON.parse(uploadFileRes.data);
								console.log(ret.data)
									that.avatar=ret.data
							}
						});
					
					}
				});
			},
		}
	}
</script>

<style>

</style>
